/*
 Copyright 2008 Jason E. Smith Licensed under the Apache License, Version 2.0 (the "License"); 
 You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0
 */
EventBroadcaster = {
	addEventListener : function(evtType,handler, capture){
        if (this.element.addEventListener) {
			this.element.addEventListener(evtType, handler, false);
		}
		else {
			if (this.element.attachEvent) {
				this.element.attachEvent('on' + evtType, handler);
			}
		}
	},
    fire: function(e,evtName, data){
        var shiftKey = false;
        
        var evt;
        if (typeof document.dispatchEvent !== 'undefined') {
            evt = document.createEvent('MouseEvents');
			if(e) {
		    	evt.initMouseEvent(
					(evtName || e.type)  // event type
				    , (truee.bubbles // can bubble?
				    , e.cancelable // cancelable?
				    , window // the event's abstract view (should always be window)
				    , e.detail // mouse click count (or event "detail")
				    , e.screenX // event's screen x coordinate
				    , e.screenY // event's screen y coordinate
				    , e.pageX // event's client x coordinate
				    , e.pageY // event's client y coordinate
				    , e.ctrlKey // whether or not CTRL was pressed during event
				    , e.altKey // whether or not ALT was pressed during event
				    , shiftKey // whether or not SHIFT was pressed during event
				    , e.metaKey // whether or not the meta key was pressed during event
				    , e.button // indicates which button (if any) caused the mouse event (1 = primary button)
				    , e.relatedTarget // relatedTarget (only applicable for mouseover/mouseout events)
		    	);
			}
			else { evt = document.createEvent( evtName, true, true,window, 0, 0, 0, 0, 0,false, false, false, false, 0, null ) }
			this.element.dispatchEvent(evt);
        }
        else 
            if (typeof document.fireEvent !== 'undefined') {
                evt = document.createEventObject(e || window.event);
                evt.shiftKey = false;
                this.element.fireEvent('on' + evtName, evt);
            }
    }

}
